package demo19_Lock;

import demo14_ForkJoin.Test02_ForkJoin;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author kunkun
 * @className Test02_Synchronized
 * @Description Synchronized外部锁获得自动锁内部
 * @date 2025/3/8 22:50
 */
public class Test02_Synchronized {
    public static void main(String[] args) {
        Test02_Synchronized test = new Test02_Synchronized();
        new Thread(()->{
            test.call();
        },"A").start();//A线程
        new Thread(()->{
            test.call();
        },"B").start();//B线程
    }
    public synchronized void call(){
        System.out.println(Thread.currentThread().getName()+"打电话");
        sms();
    }
    public synchronized void sms() {
        System.out.println(Thread.currentThread().getName()+"发邮件");
    }


}
